<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>设置我的资料</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" th:href="@{/layuiadmin/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/layuiadmin/style/admin.css}" media="all">
</head>
<body>

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">设置我的资料</div>
                    <div class="layui-card-body" pad15>
                        <from>
                            <div class="layui-form" lay-filter="">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">我的角色</label>
                                    <div class="layui-input-inline">
                                        <input th:value="${role.name}" type="text" autocomplete="off" class="layui-input layui-disabled" disabled>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">用户名</label>
                                    <div class="layui-input-inline">
                                        <input th:value="${session.admin != null}?${session.admin.username}:''" type="text" name="username" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">手机</label>
                                    <div class="layui-input-inline">
                                        <input th:value="${session.admin != null}?${session.admin.phone}:''" type="text" name="phone" lay-verify="phone" placeholder="请输入号码" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">邮箱</label>
                                    <div class="layui-input-inline">
                                        <input th:value="${session.admin != null}?${session.admin.email}:''" type="text" name="email" lay-verify="email" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit lay-filter="setmyinfo">确认修改</button>
                                        <button type="reset" id="reset" class="layui-btn layui-btn-primary">重新填写</button>
                                    </div>
                                </div>
                            </div>
                        </from>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script th:src="@{/layuiadmin/layui/layui.js}"></script>

    <script>
        layui.use(['form','jquery'], function () {
            var form = layui.form;
            var $ = layui.jquery;
            form.on('submit(setmyinfo)',function (data) {
                $.ajax({
                    url:'/manager/editInfo',
                    data:data.field,
                    dataType:'json',
                    type:'post',
                    success:function (data) {
                        if (data.success){
                            layer.msg(data.message,{time:1000});
                        }else{
                            layer.msg(data.message,{time:1000});
                        }
                    }
                });
                return false;
            })

            //重置
            $("#reset").click(function () {
                window.location.reload();
            })

        });
    </script>

</body>
</html>